@extends('common.admin-master')

@section('html-body')
    <div class="content">

        <div class="header">
            <div class="stats">
                <p class="stat"><button type="button" class="btn btn-info">添加团队</button></p>
                <p class="stat"><button type="button" class="btn btn-info">返回首页</button></p>
            </div>
            <h1 class="page-title">用户管理</h1>
        </div>

        <ul id="myTab" class="nav nav-tabs">
            <li class="active"><a href="#creater_list" data-toggle="tab">创业团队列表</a></li>
            <li><a href="#new_creater" data-toggle="tab">添加创业团队</a></li>

        </ul>

        <div class="container-fluid">
            <div class="row-fluid">

                <div class="row-fluid">
                    <div id="TabContent" class="tab-content">
                        <div class="tab-pane fade in active" id="creater_list">
                            <div class="row-fluid">
                                <div class="block span12">
                                    <a href="#tablewidget" class="block-heading" data-toggle="collapse">创业者列表<span
                                                class="label label-warning">+ </span></a>
                                    <div id="tablewidget" class="block-body collapse in">
                                        <table class="table">
                                            <thead>
                                            <tr>
                                                <th>姓名</th>
                                                <th>地区</th>
                                                <th>职位</th>
                                                <th>创业经历</th>
                                                <th width="40%">创业项目</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="pagination">
                                        <ul>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <div class="tab-pane fade" id="new_creater">
                            <div class="container-fluid">
                                <div class="row-fluid">

                                    <div class="well">
                                        <ul class="nav nav-tabs">
                                            <li class="active"><a href="#home" data-toggle="tab">创业者信息</a></li>
                                        </ul>
                                        <div id="myTabContent" class="tab-content">
                                            <div class="tab-pane active in" id="home">
                                                <label>头像</label>
                                                <em class="pro-name"></em><a class="logo" href="javascript:void(0);"
                                                                             id="inputImage"><img
                                                            id="user_logo_url" src="{{route('Api.Images.Show')}}"
                                                            title="点击上传logo" width="100" height="100" /></a><input
                                                        type="hidden" id="photo_id" value="{{\Illuminate\Support\Facades\Session::get('ImageId') == ''? 0:\Illuminate\Support\Facades\Session::get('ImageId')}}" /><em class="msg"></em><em class="c-u-d">请上传 256 x 256 以上像素的图片，</em><em class="c-u-d">格式为JPG、JPEG、PNG，小于5MB</em>
                                                <label>姓名</label>
                                                <input type="text" name="realname" class="input-xlarge">

                                                <label>所在地</label>
                                                <input type="text" name="province" class="input-xlarge">
                                                <input type="text" name="city" class="input-xlarge">

                                                <label>微信</label>
                                                <input type="text" name="wechat" class="input-xlarge">
                                                <label>微博</label>
                                                <input type="text" name="weibo" value="" class="input-xlarge">
                                                <label>脉脉</label>
                                                <input type="text" name="maimai" value="" class="input-xlarge">
                                                <label>毕业院校</label>
                                                <input type="text" name="edu_school" value="" class="input-xlarge">
                                                <label>职位</label>
                                                <input type="text" name="position" value="" class="input-xlarge">
                                                <label>个人简介</label>
                                                <textarea name="user_desc" rows="5" class="input-xlarge"></textarea>
                                                <input type="hidden" name="user_id" value="0">
                                            </div>

                                        </div>

                                        <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                <h3 id="myModalLabel">Delete Confirmation</h3>
                                            </div>
                                            <div class="modal-body">

                                                <p class="error-text"><i class="icon-warning-sign
                                            modal-icon"></i>您确定要放弃本次操作吗?</p>
                                            </div>
                                            <div class="modal-footer">
                                                <button class="btn" data-dismiss="modal" aria-hidden="true">No</button>
                                                <button class="btn btn-danger yes" data-dismiss="modal">Yes</button>
                                            </div>
                                        </div>


                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    </div>
    </div>
    <script>
        var editInvestorByAdmin  = "{{route('Api.Admin.editInvestorByAdmin')}}";
        var delInvestorByAdmin   = "{{route('Api.Admin.delUserInfoByAdmin')}}";
        var Home                 = "{{route('Admin')}}";
    </script>
    <script src="{{url('/js/admin/creater.js')}}"></script>
    <script type="text/javascript">
        $("[rel=tooltip]").tooltip();

        $('.demo-cancel-click').click(function(){return false;});

        /** tab 选项卡 */
        $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {

            var activeTab = $(e.target).text();

            var previousTab = $(e.relatedTarget).text();
            $(".active-tab span").html(activeTab);
            $(".previous-tab span").html(previousTab);
        });

        /** 头像上传 */
        var uploader = new plupload.Uploader({
            runtimes: 'html5,flash,silverlight,html4',
            browse_button: 'inputImage',
            url: '{{ url('api/upload/image')  }}',

            chunk_size: '2mb',
            filters: {
                max_file_size: '10mb',
                mime_types: [
                    {title: "Image files", extensions: "jpg,gif,png"}
                ],
                prevent_duplicates: false
            },
            multi_selection: true,
            unique_names: true,

            flash_swf_url: '{{ url('vendor/plupload-2.1.2/Moxie.swf') }}',
            silverlight_xap_url: '{{ url('vendor/plupload-2.1.2/Moxie.xap') }}',

            file_data_name: 'photo',
            headers: {
                Accept: 'application/json'
            },

            multipart_params: {
                _token: '{{ csrf_token() }}'
            },

            init: {
                PostInit: function () {
                },

                FilesAdded: function (up, files) {
                    up.start();
                },

                BeforeUpload: function (up, file) {
                    up.settings.multipart_params.file_name = file.name;
                },

                UploadProgress: function (up, file) {
                    $('.msg').html('上传中...');
                },

                Error: function (up, err) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(err.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    noty({
                        type: 'error',
                        text: err.message + ' ' + responseMessage,
                        callback: {
                            afterClose: function () {
                                $('#inputImage').show();
                                $('#inputImageProgress').hide();
                            }
                        }
                    });
                },

                FileUploaded: function (up, file, info) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(info.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    var $inputImage = $('.msg');
                    $inputImage.html('上传成功！');
                    $inputImage.show();

                    var imageUrl = '', imageId = 0;
                    if (responseObj && responseObj.data) {
                        var d = new Date();
                        imageUrl = "{{route('Api.Images.Show')}}?"+d.getTime();
                        imageId = responseObj.data.id;
                    }
                    $('#user_logo_url').attr('src', imageUrl);
                    if(imageId !== null){
                        $('#photo_id').val(imageId);
                    }else{
                        $('#photo_id').val('0');
                    }
                }
            }
        });
        uploader.init();
    </script>
@endsection


